﻿@using ForzaGT3.Data
@model Result
@{
    List<SelectListItem> DriverList = new List<SelectListItem>();
    IEnumerable<Driver> Drivers = Driver.GetAll();
    foreach (Driver data in Drivers)
    {
        SelectListItem item = new SelectListItem();
        item.Text = data.Name;
        item.Value = data.DriverId.ToString();
        DriverList.Add(item);
    }

    List<SelectListItem> SeriesList = new List<SelectListItem>();
    IEnumerable<Series> series = Series.GetAll()
        .Where(x=>x.StartDate <= DateTime.Now)
        .OrderByDescending(x=>x.StartDate);
        
    foreach (Series data in series)
    {
        SelectListItem item = new SelectListItem();
        item.Text = data.Title;
        item.Value = data.SeriesId.ToString();
        SeriesList.Add(item);
    }
}
<div class="well">
    @using (Html.BeginForm(MVC.Admin.Result.Add(), FormMethod.Post, new { @class = "form-horizontal", @enctype = "multipart/form-data" }))
    {
        <fieldset>
            <div id="legend" class="">
                <legend class="">Add Result</legend>
            </div>
            <div class="control-group">
                <!-- Select Basic -->
                <label class="control-label">
                    Series</label>
                <div class="controls">
                    @Html.DropDownListFor(x => x.SeriesId, SeriesList, new { @class = "input-xlarge" })
                </div>
            </div>
            <div class="control-group">
                <!-- Select Basic -->
                <label class="control-label">
                    Driver</label>
                <div class="controls">
                    @Html.DropDownListFor(x => x.DriverId, DriverList, new { @class = "input-xlarge" })
                </div>
            </div>
            <div class="control-group">
                <!-- Text input-->
                <label class="control-label">
                    Points</label>
                <div class="controls">
                    @Html.TextBoxFor(m => m.Point, new { @class = "input-xlarge"})
                    @Html.ValidationMessageFor(m => m.Point)
                </div>
            </div>
            <div class="control-group">
                <!-- Text input-->
                <label class="control-label">
                    Time</label>
                <div class="controls">
                    @Html.TextBoxFor(m => m.TimeElapsed, new { @class = "input-xlarge"})
                    @Html.ValidationMessageFor(m => m.TimeElapsed)
                </div>
            </div>
            <div class="control-group">
                <!-- Form Actions -->
                <div class="form-actions">
                    <button type="submit" class="btn btn-primary">
                        Save changes</button>
                    <button onclick="javascript:location.href='/Admin/Result';" type="button"
                        class="btn">
                        Cancel</button>
                </div>
            </div>
        </fieldset>
    }
</div>
